class Solution:
    def convert(self, s: str, numRows: int) -> str:
        if numRows == 1:
            return s
        s_Rows = [""]*numRows
        Row = list()
        OUT = ""
        for i in range(numRows*2 - 2):
            if i < numRows:
                Row.append(i)
            else:
                Row.append(numRows*2-2-i)
        for i in range(len(s)):
            s_Rows[Row[i%(numRows*2-2)]] += s[i]
        
        for i in range(numRows):
            OUT += s_Rows[i]
        return OUT

if __name__ == "__main__":
    s = Solution()
    print(s.convert("PAYPALISHIRING", 3)) # "PAHNAPLSIIGYIR"
    print(s.convert("PAYPALISHIRING", 4)) # "PINALSIGYAHRPI"
    print(s.convert("A", 1)) # "A"